/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesRecordPageRequest;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesRecordQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesRecordDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICasePartiesRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseDetailPartiesInfoVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CasePartiesDetailInfoVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CasePartiesInfoVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CasePartiesRecordVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 描述: 案件当事人表-TRJ case_parties_info 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月15日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/caseParties")
@Slf4j
public class CasePartiesRecordController extends BaseController {
    @Resource
    private ICasePartiesRecordService casePartiesRecordService;

    /**
     * 【V1.0.0】描述：保存案件当事人信息
     *
     * @param saveDto {@link CasePartiesRecordDto}
     * @return {@link Result <String>} 保存结果
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/saveCasePartiesInfo")
    @ApiOperation(value = "【V1.0.0】描述：保存案件当事人信息", httpMethod = "POST")
    public Result<String> saveCasePartiesInfo(@RequestBody @Validated CasePartiesRecordDto saveDto) {
        int count = casePartiesRecordService.saveCasePartiesInfo(saveDto);
        return (count == Constant.INTEGER_1) ?
                Result.success(Constant.STRING_SAVE_SUCCESS) : Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 【V1.0.0】描述：获取案件当事人信息分页列表
     *
     * @param pageRequest {@link CasePartiesRecordPageRequest}
     * @return {@link Result<  PageResponse  < CasePartiesRecordVo >>} 案件当事人信息分页列表
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesInfoPageList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件当事人信息分页列表", httpMethod = "POST")
    public Result<PageResponse<CasePartiesRecordVo>> getCasePartiesInfoPageList(@RequestBody @Validated CasePartiesRecordPageRequest pageRequest) {
        List<CasePartiesRecordVo> list = casePartiesRecordService.getCasePartiesInfoPageList(pageRequest);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(list));
    }

    /**
     * 【V2.0.0】描述：获取案件当事人信息列表
     *
     * @param queryDto {@link CasePartiesRecordQueryDto}
     * @return {@link Result<List< CasePartiesInfoVo >>} 案件当事人信息列表
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesInfoList")
    @ApiOperation(value = "【V2.0.0】描述：获取案件当事人信息列表", httpMethod = "POST")
    public Result<List<CasePartiesInfoVo>> getCasePartiesInfoList(@RequestBody @Validated CasePartiesRecordQueryDto queryDto) {
        List<CasePartiesInfoVo> list = casePartiesRecordService.getCasePartiesInfoList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：根据案件id查询案件当事人信息
     *
     * @param caseId 案件id
     * @return {@link Result<List< CasePartiesRecordVo >>} 案件当事人信息
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据案件id查询案件当事人信息", httpMethod = "POST")
    public Result<List<CasePartiesRecordVo>> getCasePartiesInfo(@RequestParam String caseId) {
        List<CasePartiesRecordVo> casePartiesInfo = casePartiesRecordService.getCasePartiesInfo(caseId);
        return Result.success(Constant.STRING_GET_SUCCESS, casePartiesInfo);
    }

    /**
     * 【V1.0.0】描述：根据案件id查询案件当事人详细信息（具体返回个人/法人信息）
     *
     * @param caseId 案件id
     * @return {@link Result< CasePartiesDetailInfoVo >} 案件当事人详细信息（具体返回个人/法人信息）
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesDetailInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据案件id查询案件当事人详细信息（具体返回个人/法人信息）", httpMethod = "POST")
    public Result<CasePartiesDetailInfoVo> getCasePartiesDetailInfo(@RequestParam String caseId) {
        CasePartiesDetailInfoVo vo = casePartiesRecordService.getCasePartiesDetailInfo(caseId);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 【V1.0.0】描述：删除案件当事人信息
     *
     * @param id 主键id
     * @return {@link Result<String>} 删除结果
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/removeCasePartiesInfo")
    @ApiOperation(value = "【V1.0.0】描述：删除案件当事人信息", httpMethod = "POST")
    public Result<String> removeCasePartiesInfo(@RequestParam String id) {
        return casePartiesRecordService.removeCasePartiesInfo(id);
    }


    /**
     * 描述：获取当事人id、名称信息
     *
     * @param caseId 案件id
     * @return Result<Map<String, String>>  当事人id、名称信息（多当事人时id、name逗号分隔）
     * 返回示例：{partyId:"1001",partyName:"张三"}
     * @author xiangyuyu
     * @date 2022-05-26 15:49
     */
    @PostMapping("/getCasePartyIdNameInfo")
    @ApiOperation(value = "描述：获取当事人id、名称信息", httpMethod = "POST")
    public Result<Map<String, String>> getCasePartyIdNameInfo(@RequestParam String caseId) {
        Map<String, String> map = casePartiesRecordService.getCasePartyIdNameInfo(caseId);
        return Result.success(map);
    }
    /**
     * 获取当事人信息(案件详情-新)
     * @author liyafeng
     * @date 2022/8/3
      * @param caseId
     * @return {@link Result< Map< String, String>>}
     */
    @PostMapping("/getCaseDetailPartyInfo")
    public Result<List<CaseDetailPartiesInfoVo>> getCaseDetailPartyInfo(@RequestParam String caseId) {
        List<CaseDetailPartiesInfoVo> caseDetailPartiesInfoVos = casePartiesRecordService.getCaseDetailPartyInfo(caseId);
        return Result.success(caseDetailPartiesInfoVos);
    }


}
